home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 February / macformat-047.iso / Demos / Simpsons Cartoon Studio™ Demo / Simpdata / simpmain / 00018_recordMethods parent.ls < prev    next >
Encoding:
Text File  |  1996-09-06  |  4.5 KB  |  139 lines

  1. global curDataChannel, animatedPropList, firstClip, theRecordingLayer, referenceFrameNum, curClipRecord, enterList, loopList, exitList, theStageBounds, theLayer, dispatchTable, frameLimit, foregroundFXSpr, backgroundFXSpr, autoHoldFrame, dirtyFlag
  2.  
  3. on birth me
  4.   return me
  5. end
  6.  
  7. on moveRecordingSpr me, whichSpr, theMouseH, theMouseV
  8.   set theMouseLoc to point(theMouseH, theMouseV)
  9.   if the shiftDown then
  10.     cursor(3)
  11.     set the loc of sprite whichSpr to theMouseLoc
  12.   else
  13.     if inside(theMouseLoc, theStageBounds) then
  14.       cursor(200)
  15.       set the loc of sprite whichSpr to point(theMouseH, theMouseV)
  16.     else
  17.       cursor(-1)
  18.       hideRecordingSpr(me, whichSpr)
  19.     end if
  20.   end if
  21.   updateStage()
  22. end
  23.  
  24. on setupClipData me
  25.   set enterList to getAt(curClipRecord, 4)
  26.   set loopList to getAt(curClipRecord, 5)
  27.   set exitList to getAt(curClipRecord, 6)
  28.   preloadClipData(me)
  29.   if enterList <> [] then
  30.     set firstClip to getAt(enterList, 1)
  31.   else
  32.     if loopList <> [] then
  33.       set firstClip to getAt(loopList, 1)
  34.     else
  35.       set firstClip to getAt(exitList, 1)
  36.     end if
  37.   end if
  38.   set the castNum of sprite theRecordingLayer to firstClip
  39. end
  40.  
  41. on preloadClipData me
  42.   if enterList <> [] then
  43.     repeat with theCastNumber in enterList
  44.       preLoadCast(theCastNumber)
  45.     end repeat
  46.   end if
  47.   if loopList <> [] then
  48.     repeat with theCastNumber in loopList
  49.       preLoadCast(theCastNumber)
  50.     end repeat
  51.   end if
  52.   if exitList <> [] then
  53.     repeat with theCastNumber in exitList
  54.       preLoadCast(theCastNumber)
  55.     end repeat
  56.   end if
  57. end
  58.  
  59. on hideRecordingSpr me, whichSpr
  60.   set the locH of sprite whichSpr to -1000
  61. end
  62.  
  63. on buildFilterList me
  64.   set theFrameMap to [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  65.   set animatedPropList to []
  66.   set autoHoldFrame to copyList(getAt(scoreData, referenceFrameNum))
  67.   repeat with theChannelNumber = 1 to 12
  68.     if getAt(autoHoldFrame, theChannelNumber) <> EMPTY then
  69.       setAt(theFrameMap, theChannelNumber, 1)
  70.     end if
  71.   end repeat
  72.   set theType to getAt(curClipRecord, 1)
  73.   if (theType <> "L") and (theType <> "N") then
  74.     if (theLayer <> foregroundFXSpr) and (theLayer <> backgroundFXSpr) then
  75.       setAt(theFrameMap, curDataChannel, 0)
  76.     end if
  77.   end if
  78.   set theSlotCount to 1
  79.   repeat with theSlot in dispatchTable
  80.     set theType to getAt(theSlot, 1)
  81.     set theChannelNumber to getAt(theSlot, 3)
  82.     if (theType = "P") or (theType = "S") then
  83.       if theType = "S" then
  84.         setAt(theFrameMap, theChannelNumber, 0)
  85.       end if
  86.     else
  87.       setAt(autoHoldFrame, theChannelNumber, [])
  88.       setAt(theFrameMap, theChannelNumber, 0)
  89.     end if
  90.     set theSlotCount to theSlotCount + 1
  91.   end repeat
  92.   set theSlotCount to 1
  93.   repeat with theSlot in dispatchTable
  94.     set theChannelNumber to getAt(theSlot, 3)
  95.     if getAt(theFrameMap, theChannelNumber) = 1 then
  96.       append(animatedPropList, theSlotCount)
  97.     end if
  98.     set theSlotCount to theSlotCount + 1
  99.   end repeat
  100. end
  101.  
  102. on extendClips me
  103.   repeat with theSlotNumber in animatedPropList
  104.     set theSlot to getAt(dispatchTable, theSlotNumber)
  105.     set theChannelNumber to getAt(theSlot, 3)
  106.     set theSearchField to getAt(theSlot, 4)
  107.     set theLineCount to the number of lines in field theSearchField
  108.     set theSearchString to string(getAt(theSlot, 2))
  109.     repeat with theLineNumber = 1 to theLineCount
  110.       if value(item 2 of line theLineNumber of field theSearchField) = theSearchString then
  111.         set thePropClipRecord to value(line theLineNumber of field theSearchField)
  112.         exit repeat
  113.       end if
  114.     end repeat
  115.     if not voidp(thePropClipRecord) then
  116.       set theLoopList to getAt(thePropClipRecord, 5)
  117.       set theLoopCount to count(theLoopList)
  118.       set theLoopNumber to 1
  119.       set referenceClip to copyList(getAt(getAt(scoreData, referenceFrameNum), theChannelNumber))
  120.       repeat with theFrameNumber = referenceFrameNum + 1 to count(scoreData)
  121.         set newReferenceClip to copyList(referenceClip)
  122.         setAt(newReferenceClip, 1, getAt(theLoopList, theLoopNumber))
  123.         setAt(getAt(scoreData, theFrameNumber), theChannelNumber, newReferenceClip)
  124.         if theLoopNumber < theLoopCount then
  125.           set theLoopNumber to theLoopNumber + 1
  126.           next repeat
  127.         end if
  128.         set theLoopNumber to 1
  129.       end repeat
  130.     end if
  131.   end repeat
  132. end
  133.  
  134. on showOverFlowDialog me
  135.   set theMessage to "Sorry, you cannot record more than " & frameLimit - 1 & " frames.  The full version of Simpsons Cartoon Studio allows you to create cartoons of up to 1,200 frames."
  136.   set theAlertBoxType to #OK
  137.   showTheAlertBox(theMessage, theAlertBoxType, "nothing", "nothing", "nothing")
  138. end
  139.